import sys
import os
from PySide6.QtWidgets import *
from PySide6.QtGui import *
from PySide6.QtCore import *

class Demo(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.parent = parent

        self.stackedLayout = QStackedLayout()
        self.stackedLayout.addWidget(QLabel('Page1',parent=self))
        self.stackedLayout.addWidget(QLabel('Page2',parent=self))
        self.stackedLayout.addWidget(QLabel('Page3',parent=self))
        
        pageComboBox = QComboBox()
        pageComboBox.addItem("Page 1")
        pageComboBox.addItem("Page 2")
        pageComboBox.addItem("Page 3")
        pageComboBox.activated.connect(self.OnIndexChaged)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(self.stackedLayout)
        mainLayout.addWidget(pageComboBox)
        self.setLayout(mainLayout)
    
    def OnIndexChaged(self,event):
        self.stackedLayout.setCurrentIndex(event)
        self.parent.OnShowMessage(f'Change StackedLayout CurrentIndex to {event}')
def runDemo(parent):
    wigdet =  Demo(parent)
    return wigdet